/**
 * 
 */
package de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.tests;
import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import org.junit.Before;
import org.junit.Test;
import de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.CSVTokenizer;
import de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.Tokenizer;
/**
 * 
 * @author Christoph Teichmann
 * created Jun 7, 2014 4:06:43 PM
 * @version 0.1
 */
public class TestCSVTokenizer
{
	/**
	 * 
	 */
	private Tokenizer tokD;
	/**
	 * 
	 */
	private Tokenizer tokU;
	/**
	 *
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		tokD = new CSVTokenizer(true);
		tokU = new CSVTokenizer(false);
	}
	/**
	 * Test method for {@link de.uni_leipzig.informatik.asv.unsupervised_pos_tagger.datacreation.CSVTokenizer#setToNext()}.
	 * @throws IOException 
	 */
	@Test
	public final void testSetToNext() throws IOException
	{
		StringReader sr = new StringReader(TestStrings.ALIGNMENTS);
		BufferedReader br = new BufferedReader(sr);
		tokD.readFrom(br);
		sr = new StringReader(TestStrings.ALIGNMENTS);
		br = new BufferedReader(sr);
		tokU.readFrom(br);
		int pos = 0;
		while(tokD.hasNext())
		{
			tokD.setToNext();
			if(pos == 9)
			{
				assertEquals(tokD.currentWord(), "jahre");
				assertEquals(tokD.currentLanguage(), "DEUTSCH");
			}
			++pos;
		}
		pos = 0;
		while(tokU.hasNext())
		{
			tokU.setToNext();
			if(pos == 9)
			{
				assertEquals(tokU.currentWord(), "Jahre");
				assertEquals(tokU.currentLanguage(), "DEUTSCH");
			}
			++pos;
		}
	}
}
